﻿
CREATE PROCEDURE [dbo].[GoodsForDefekturaUpdate]
(
	@CategoryId int,
	@Original_Id int
)
AS

UPDATE PR.DefekturaGoods 
SET DefekturaCategoryId = @CategoryId,
SaleDays = null,
FullDays = null,
PresenceCoef = null
WHERE GoodsId = @Original_Id

IF @@rowcount = 0
	INSERT INTO PR.DefekturaGoods (GoodsId, DefekturaCategoryId)
	VALUES (@Original_Id, @CategoryId)

RETURN 0
